#if !defined(AFX_DATASOCKET_H__38ADA982_DD96_4607_B7D2_982011F162FE__INCLUDED_)
#define AFX_DATASOCKET_H__38ADA982_DD96_4607_B7D2_982011F162FE__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CControlSocket;

class CDataSocket : public CAsyncSocket
{
public:
	CDataSocket(CControlSocket *pSocket);
	virtual ~CDataSocket();
	BOOL m_bConnected;

public:
	void SendFile(LPCTSTR lpszFilename);
	void RetrieveFile(LPCTSTR lpszFilename);
	void SendListing(LPCTSTR lpszListing);

	//{{AFX_VIRTUAL(CDataSocket)
	public:
	virtual void OnSend(int nErrorCode);
	virtual void OnConnect(int nErrorCode);
	virtual void OnClose(int nErrorCode);
	virtual void OnReceive(int nErrorCode);
	virtual void OnAccept(int nErrorCode);
	//}}AFX_VIRTUAL

	//{{AFX_MSG(CDataSocket)
	//}}AFX_MSG

protected:
	int Receive();
	
	BOOL PrepareReceiveFile(LPCTSTR lpszFilename);
	BOOL PrepareSendFile(LPCTSTR lpszFilename);
	
	DWORD m_nTotalBytesTransfered;
	DWORD m_nTotalBytesReceive;
	DWORD m_nTotalBytesSend;

	CFile m_File;
	CString m_strListing;

	CControlSocket *m_pControlSocket;
};


//{{AFX_INSERT_LOCATION}}

#endif // AFX_DATASOCKET_H__38ADA982_DD96_4607_B7D2_982011F162FE__INCLUDED_
